package org.example.baizhi.service;

import org.example.baizhi.annotaions.RedisCache;
import org.example.baizhi.dao.EmpDAO;
import org.example.baizhi.entity.Emp;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;
import java.util.UUID;

@Service
@Transactional
public class EmpServiceImpl implements EmpService{

    @Resource
    private EmpDAO empDAO;


    @Override
    @RedisCache(value1 = "员工模块的缓存")
    public List<Emp> findAll() {
        return empDAO.findAll();
    }

    @Override
    public Emp find(String id) {
        return empDAO.find(id);
    }

    @Override
    public void save(Emp emp) {
        emp.setId(UUID.randomUUID().toString());
        empDAO.save(emp);
    }


}
